<?php

namespace App\Containers\AppSection\Dadata\Tasks;

use App\Containers\AppSection\Dadata\Traits\DadataTaskTrait;
use App\Ship\Exceptions\BadRequestException;
use App\Ship\Parents\Tasks\Task;
use Dadata\Settings;
use Exception;

class FindByIdDadataTask extends Task
{
    use DadataTaskTrait;

    public function run($name, $query, $count = Settings::SUGGESTION_COUNT, $kwargs = [])
    {
        try {
            return $this->dadata->findById($name, $query, $count, $kwargs);
        } catch (Exception $exception) {
            throw new BadRequestException();
        }
    }
}
